function MainAssistant() {
	/* this is the creator function for your scene assistant object. It will be passed all the 
	   additional parameters (after the scene name) that were passed to pushScene. The reference
	   to the scene controller (this.controller) has not be established yet, so any initialization
	   that needs the scene controller should be done in the setup function below. */
}

MainAssistant.prototype.setup = function() {
	try {
		// Setup Application Menu
		this.controller.setupWidget(Mojo.Menu.appMenu, appMenuAttr, appMenuModel);
		
		// Check for settings cookie
		this.cookie = new Mojo.Model.Cookie("SageData");
		var data = this.cookie.get();
		if (data) {
			if (data.username && data.password && data.server && data.instance) {
				username = data.username;
				password = data.password;
				server = data.server;
				https = data.https;
				if(data.admobToggle) {
					admobToggle = data.admobToggle;
				} else {
					admobToggle = "enabled";
				}
				sage_instance = escape(data.instance);
//				sage_header_label = 'SageTV - Remote';
				sage_header_label = 'SageTV - ' + data.label;
				if(https == 1) {
					url = 'https:// ' + username + ':' + password + '@' + server + '/sage/';
				} else {
					url = 'http://' + username + ':' + password + '@' + server + '/sage/';
				}
				if(data.clients) {
					if(data.clients.length <! 1) {
						clients = data.clients;
					} else {
						clients = new Array;
						clients[0] = {
							label: 'Local Server',
							value: 'SAGETV_PROCESS_LOCAL_UI'
						};
					}
				} else {
					clients = new Array;
					clients[0] = {
						label: 'Local Server',
						value: 'SAGETV_PROCESS_LOCAL_UI'
					};
				}
			}
		} else {
			admobToggle = "enabled";
			Mojo.Controller.stageController.pushScene("settings");
		}
		
		// Secret AdMob Remover
		if(admobToggle == "disabled") {
			void($('admobHTMLLocation').innerHTML = null);
		} else {
			this.admobEnabled();
		}
		
		// Setup Widgets
		//// Media Keys
		this.controller.setupWidget("power_button", // "Power" button
			this.attributes = {
				},
			this.model = {
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('power_button'), Mojo.Event.tap, this.Power.bind(this));

		this.controller.setupWidget("home_button", // Home button
			this.attributes = {
				},
			this.model = {
				label : "Home",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('home_button'), Mojo.Event.tap, this.Home.bind(this));

		this.controller.setupWidget("sage_recordings_button", // Recorded TV
			this.attributes = {
				},
			this.model = {
				label : "Rec. TV",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('sage_recordings_button'), Mojo.Event.tap, this.sageRecordings.bind(this));
	
		this.controller.setupWidget("recording_sched_button", // List of upcoming recordings
			this.attributes = {
				},
			this.model = {
				label : "Rec. Sched",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('recording_sched_button'), Mojo.Event.tap, this.RecordingSched.bind(this));
		
		this.controller.setupWidget("fullscreen_button", // Fullscreen
			this.attributes = {
				},
			this.model = {
				label : "Fullscreen",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('fullscreen_button'), Mojo.Event.tap, this.Fullscreen.bind(this));
	
		this.controller.setupWidget("settings_button", // Settings
			this.attributes = {
				},
			this.model = {
				label : "Settings",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('settings_button'), Mojo.Event.tap, this.Settings.bind(this));
		
		this.controller.setupWidget("livetv_button", // Live TV
			this.attributes = {
				},
			this.model = {
				label : "Now Playing",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('livetv_button'), Mojo.Event.tap, this.LiveTV.bind(this));
	
		this.controller.setupWidget("guide_button", // Guide
			this.attributes = {
				},
			this.model = {
				label : "Guide",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('guide_button'), Mojo.Event.tap, this.Guide.bind(this));

		this.controller.setupWidget("info_button", // Info
			this.attributes = {
				},
			this.model = {
				label : "Info",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('info_button'), Mojo.Event.tap, this.Info.bind(this));
	
		this.controller.setupWidget("videos_button", // Videos
			this.attributes = {
				},
			this.model = {
				label : "Videos",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('videos_button'), Mojo.Event.tap, this.VidLibrary.bind(this));
		
		this.controller.setupWidget("music_button", // Music
			this.attributes = {
				},
			this.model = {
				label : "Music",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('music_button'), Mojo.Event.tap, this.MusicLibrary.bind(this));
	
		this.controller.setupWidget("photos_button", // Photos
			this.attributes = {
				},
			this.model = {
				label : "Photos",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('photos_button'), Mojo.Event.tap, this.PicLibrary.bind(this));
		
		this.controller.setupWidget("record_button", // Record Button
			this.attributes = {
				},
			this.model = {
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('record_button'), Mojo.Event.tap, this.recordButton.bind(this));
		
		this.controller.setupWidget("pause_button", // Pause Button
			this.attributes = {
				},
			this.model = {
				label : "Pause",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('pause_button'), Mojo.Event.tap, this.pauseButton.bind(this));

		this.controller.setupWidget("stop_button", // Stop Button
			this.attributes = {
				},
			this.model = {
				label : "Stop",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('stop_button'), Mojo.Event.tap, this.stopButton.bind(this));

		this.controller.setupWidget("fr_button", // Fast Rewind
			this.attributes = {
				},
			this.model = {
				label : "<<",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('fr_button'), Mojo.Event.tap, this.frButton.bind(this));

		this.controller.setupWidget("play_button", // Play Button
			this.attributes = {
				},
			this.model = {
				label : "Play",
				buttonClass: 'affirmative',
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('play_button'), Mojo.Event.tap, this.playButton.bind(this));

		this.controller.setupWidget("ff_button", // Fast Forward
			this.attributes = {
				},
			this.model = {
				label : ">>",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('ff_button'), Mojo.Event.tap, this.ffButton.bind(this));

		this.controller.setupWidget("rskip_button", // Reverse Skip
			this.attributes = {
				},
			this.model = {
				label : "|<<",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('rskip_button'), Mojo.Event.tap, this.rskipButton.bind(this));

		this.controller.setupWidget("del_button", // Delete Button
			this.attributes = {
				},
			this.model = {
				label : "Del.",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('del_button'), Mojo.Event.tap, this.delButton.bind(this));

		this.controller.setupWidget("fskip_button", // Forward Skip
			this.attributes = {
				},
			this.model = {
				label : ">>|",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('fskip_button'), Mojo.Event.tap, this.fskipButton.bind(this));
		
		this.controller.setupWidget("num1_button", // Number One
			this.attributes = {
				},
			this.model = {
				label : "1",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num1_button'), Mojo.Event.tap, this.num1Button.bind(this));
		
		this.controller.setupWidget("num2_button", // Number Two
			this.attributes = {
				},
			this.model = {
				label : "2",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num2_button'), Mojo.Event.tap, this.num2Button.bind(this));
		
		this.controller.setupWidget("num3_button", // Number Three
			this.attributes = {
				},
			this.model = {
				label : "3",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num3_button'), Mojo.Event.tap, this.num3Button.bind(this));
		
		this.controller.setupWidget("num4_button", // Number Four
			this.attributes = {
				},
			this.model = {
				label : "4",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num4_button'), Mojo.Event.tap, this.num4Button.bind(this));
		
		this.controller.setupWidget("num5_button", // Number Five
			this.attributes = {
				},
			this.model = {
				label : "5",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num5_button'), Mojo.Event.tap, this.num5Button.bind(this));
		
		this.controller.setupWidget("num6_button", // Number Six
			this.attributes = {
				},
			this.model = {
				label : "6",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num6_button'), Mojo.Event.tap, this.num6Button.bind(this));
		
		this.controller.setupWidget("num7_button", // Number Seven
			this.attributes = {
				},
			this.model = {
				label : "7",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num7_button'), Mojo.Event.tap, this.num7Button.bind(this));
		
		this.controller.setupWidget("num8_button", // Number Eight
			this.attributes = {
				},
			this.model = {
				label : "8",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num8_button'), Mojo.Event.tap, this.num8Button.bind(this));
	
		this.controller.setupWidget("num9_button", // Number Nine
			this.attributes = {
				},
			this.model = {
				label : "9",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num9_button'), Mojo.Event.tap, this.num9Button.bind(this));
		
		this.controller.setupWidget("num0_button", // Number Zero
			this.attributes = {
				},
			this.model = {
				label : "0",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('num0_button'), Mojo.Event.tap, this.num0Button.bind(this));

		this.controller.setupWidget("chUp_button", // Channel Up
			this.attributes = {
				},
			this.model = {
				label : "Ch +",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('chUp_button'), Mojo.Event.tap, this.chUpButton.bind(this));
		
		this.controller.setupWidget("chDown_button", // Channel Down
			this.attributes = {
				},
			this.model = {
				label : "Ch -",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('chDown_button'), Mojo.Event.tap, this.chDownButton.bind(this));

		this.controller.setupWidget("prevCh_button", // Last Channel
			this.attributes = {
				},
			this.model = {
				label : "Prev Ch",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('prevCh_button'), Mojo.Event.tap, this.lastChButton.bind(this));
		
		this.controller.setupWidget("volUp_button", // Volume Up
			this.attributes = {
				},
			this.model = {
				label : "Vol +",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('volUp_button'), Mojo.Event.tap, this.volUpButton.bind(this));
		
		this.controller.setupWidget("volDown_button", // Volume Down
			this.attributes = {
				},
			this.model = {
				label : "Vol -",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('volDown_button'), Mojo.Event.tap, this.volDownButton.bind(this));
		
		this.controller.setupWidget("mute_button", // Mute
			this.attributes = {
				},
			this.model = {
				label : "Mute",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('mute_button'), Mojo.Event.tap, this.muteButton.bind(this));
		
		this.controller.setupWidget("arrowUp_button", // Arrow Up
			this.attributes = {
				},
			this.model = {
				label : "Up",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('arrowUp_button'), Mojo.Event.tap, this.arrowUpButton.bind(this));
		
		this.controller.setupWidget("arrowLeft_button", // Arrow Left
			this.attributes = {
				},
			this.model = {
				label : "Left",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('arrowLeft_button'), Mojo.Event.tap, this.arrowLeftButton.bind(this));
		
		this.controller.setupWidget("arrowRight_button", // Arrow Right
			this.attributes = {
				},
			this.model = {
				label : "Right",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('arrowRight_button'), Mojo.Event.tap, this.arrowRightButton.bind(this));
		
		this.controller.setupWidget("arrowDown_button", // Arrow Down
			this.attributes = {
				},
			this.model = {
				label : "Down",
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('arrowDown_button'), Mojo.Event.tap, this.arrowDownButton.bind(this));
		
		this.controller.setupWidget("enter_button", // Enter Button
			this.attributes = {
				},
			this.model = {
				label : "Enter",
				buttonClass: 'affirmative',
				disabled: false
			});
		Mojo.Event.listen(this.controller.get('enter_button'), Mojo.Event.tap, this.enterButton.bind(this));
		
		// Drawers
		//// Media Keys
		this.controller.setupWidget("mediaKeysDrawer",
			{property:'myOpenProperty'},
			{myOpenProperty:false}
		);
		Mojo.Event.listen(this.controller.get('mediaKeysDiv'), Mojo.Event.tap, this.toggleMediaDrawer.bind(this));
		//// Playback Controls
		this.controller.setupWidget("playbackDrawer",
			{property:'myOpenProperty'},
			{myOpenProperty:false}
		);
		Mojo.Event.listen(this.controller.get('playbackDiv'), Mojo.Event.tap, this.togglePlaybackDrawer.bind(this));
		//// Number Pad
		this.controller.setupWidget("numberPadDrawer",
			{property:'myOpenProperty'},
			{myOpenProperty:false}
		);
		Mojo.Event.listen(this.controller.get('numberPadDiv'), Mojo.Event.tap, this.toggleNumberPadDrawer.bind(this));
		//// Navigation
		this.controller.setupWidget("navigationDrawer",
			{property:'myOpenProperty'},
			{myOpenProperty:false}
		);
		Mojo.Event.listen(this.controller.get('navigationDiv'), Mojo.Event.tap, this.toggleNavigationDrawer.bind(this));
		
		// Command Buttons
		//// Header Menu
//		this.controller.setupWidget(Mojo.Menu.viewMenu, undefined,
//			{label: data.label, submenu:'client-menu'});
//		this.controller.setupWidget('client-menu', undefined, {items: clients});
		//// Forward & Back
		this.controller.setupWidget(Mojo.Menu.commandMenu, undefined, 
			{items:	[
				{icon: 'back', command:'cmd-back'},
				{icon: 'forward', command:'cmd-fwrd'}
		]});
	} catch(err) {
		this.showDialogBox('Error', err);
	}
}

// AdMob request function
MainAssistant.prototype.admobRequest = function() {
	try {
		void($('admobSpawn').innerHTML=null);
		AdMob.ad.request({
			onSuccess: (function (ad) { // successful ad call, parameter 'ad' is the html markup for the ad
					this.controller.get('admobSpawn').insert(ad); // place markup in the the previously declared div
//					this.showDialogBox('Admob Request Success', 'Error code: '+ad_err_status+'\r\nInfo: '+ad_err_statusText+'\r\nServer Response: '+ad_err_response);
			}).bind(this),
			onFailure: (function (ad_err_status,ad_err_statusText,ad_err_response) { // no ad was returned or call was unsuccessful
				void($('admobSpawn').innerHTML="<div style=\"padding-left:10px; font-size:18px\"><span><strong>Unable to fetch AdMob ad.</strong><br />Consider donating...&nbsp;<a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_donations&amp;business=thegodfaza%40gmail%2ecom&amp;lc=US&amp;item_name=SageTV%20Remote&amp;currency_code=USD&amp;bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted\" rel=\"nofollow\"><img alt=\"\" src=\"images/btn_donate_SM.gif\" /></a></div>");
//				this.showDialogBox('Admob Request Failure', 'Error code: '+ad_err_status+'\r\nInfo: '+ad_err_statusText+'\r\nServer Response: '+ad_err_response);
			}).bind(this),
		});
	} catch(err) {
		this.showDialogBox('Error', err);
	}
}

MainAssistant.prototype.admobEnabled = function() {
	// Setup AdMob
	//// Request an AdMob ad
	this.admobRequest();

	//// AdMob ad
	this.controller.setupWidget("admobDrawer",
		{property:'myOpenProperty'},
		{myOpenProperty:true}
	);
	Mojo.Event.listen(this.controller.get('admobDiv'), Mojo.Event.tap, this.toggleAdMobDrawer.bind(this));
}

// Open my drawers!!! please...
//// AdMob drawer function
MainAssistant.prototype.toggleAdMobDrawer = function() {
	this.Drawer = this.controller.get('admobDrawer');
	this.Drawer.mojo.setOpenState(!this.Drawer.mojo.getOpenState());
	this.Div = this.controller.get('admobButton');
//	this.Drawer.addClassName('palm-dark');
//	this.Div.addClassName('palm-dark');
	if(this.Div.hasClassName('palm-arrow-expanded')) {
		this.Div.addClassName('palm-arrow-closed');
		this.Div.removeClassName('palm-arrow-expanded');
	} else if(this.Div.hasClassName('palm-arrow-closed')) {
		this.admobRequest();
		this.Div.addClassName('palm-arrow-expanded');
		this.Div.removeClassName('palm-arrow-closed');
	}
}

MainAssistant.prototype.toggleMediaDrawer = function() {
	this.Drawer = this.controller.get('mediaKeysDrawer');
	this.Drawer.mojo.setOpenState(!this.Drawer.mojo.getOpenState());
	this.Div = this.controller.get('mediaKeysButton');
//	this.Div.addClassName('palm-dark');
//	this.Drawer.addClassName('palm-dark');
	if(this.Div.hasClassName('palm-arrow-expanded')) {
		this.Div.addClassName('palm-arrow-closed');
		this.Div.removeClassName('palm-arrow-expanded');
	} else if(this.Div.hasClassName('palm-arrow-closed')) {
		this.Div.addClassName('palm-arrow-expanded');
		this.Div.removeClassName('palm-arrow-closed');
	}
}

MainAssistant.prototype.togglePlaybackDrawer = function() {
	this.Drawer = this.controller.get('playbackDrawer');
	this.Drawer.mojo.setOpenState(!this.Drawer.mojo.getOpenState());
	this.Div = this.controller.get('playbackButton');
//	this.Drawer.addClassName('palm-dark');
//	this.Div.addClassName('palm-dark');
	if(this.Div.hasClassName('palm-arrow-expanded')) {
		this.Div.addClassName('palm-arrow-closed');
		this.Div.removeClassName('palm-arrow-expanded');
	} else if(this.Div.hasClassName('palm-arrow-closed')) {
		this.Div.addClassName('palm-arrow-expanded');
		this.Div.removeClassName('palm-arrow-closed');
	}
}

MainAssistant.prototype.toggleNumberPadDrawer = function() {
	this.Drawer = this.controller.get('numberPadDrawer');
	this.Drawer.mojo.setOpenState(!this.Drawer.mojo.getOpenState());
	this.Div = this.controller.get('numberPadButton');
//	this.Drawer.addClassName('palm-dark');
//	this.Div.addClassName('palm-dark');
	if(this.Div.hasClassName('palm-arrow-expanded')) {
		this.Div.addClassName('palm-arrow-closed');
		this.Div.removeClassName('palm-arrow-expanded');
	} else if(this.Div.hasClassName('palm-arrow-closed')) {
		this.Div.addClassName('palm-arrow-expanded');
		this.Div.removeClassName('palm-arrow-closed');
	}
}

MainAssistant.prototype.toggleNavigationDrawer = function() {
	this.Drawer = this.controller.get('navigationDrawer');
	this.Drawer.mojo.setOpenState(!this.Drawer.mojo.getOpenState());
	this.Div = this.controller.get('navigationButton');
//	this.Drawer.addClassName('palm-dark');
//	this.Div.addClassName('palm-dark');
	if(this.Div.hasClassName('palm-arrow-expanded')) {
		this.Div.addClassName('palm-arrow-closed');
		this.Div.removeClassName('palm-arrow-expanded');
	} else if(this.Div.hasClassName('palm-arrow-closed')) {
		this.Div.addClassName('palm-arrow-expanded');
		this.Div.removeClassName('palm-arrow-closed');
	}
}

MainAssistant.prototype.showDialogBox = function (title, message) {
	this.controller.showAlertDialog({
		onChoose: function (value) {},
		title: title,
		message: message,
		allowHTMLMessage: true,
		choices: [ {label: 'OK', value: 'OK', type: 'color'} ]
	});
};

MainAssistant.prototype.activate = function(event) {
	this.cookie = new Mojo.Model.Cookie("SageData");
	var data = this.cookie.get();
	if (data) {
		if (data.label) {
			void($('page-title').innerHTML = 'SageTV - ' + data.label);
		}
	}
	// CSS Rules
	$$('body')[0].addClassName('palm-dark');
	$$('body')[0].addClassName('main');
	$$('body')[0].removeClassName('palm-default');
}

MainAssistant.prototype.deactivate = function(event) {
	/* remove any event handlers you added in activate and do any other cleanup that should happen before
	   this scene is popped or another scene is pushed on top */
	$$('body')[0].addClassName('palm-default');
	$$('body')[0].removeClassName('main');
	$$('body')[0].removeClassName('palm-dark');
}

MainAssistant.prototype.cleanup = function(event) {
	/* this function should do any cleanup needed before the scene is destroyed as 
	   a result of being popped off the scene stack */
}

// Functions for each button since I can't call a function and pass variables from within an event listener. :(
MainAssistant.prototype.sageRecordings = function() { // List recorded TV
	var query = 'SageCommand?context='+sage_instance+'&command=SageTV%20Recordings';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.RecordingSched = function() { // List upcoming recordings
	var query = 'SageCommand?context='+sage_instance+'&command=Recording%20Schedule';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.Power = function() { // "Power" button
	var query = 'SageCommand?context='+sage_instance+'&command=Power';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.Home = function() { // Home button
	var query = 'SageCommand?context='+sage_instance+'&command=Home';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.Fullscreen = function() { // Fullscreen
	var query = 'SageCommand?context='+sage_instance+'&command=Full%20Screen';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.Settings = function() { // Settings
	var query = 'SageCommand?context='+sage_instance+'&command=Setup';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.LiveTV = function() { // Live TV
	var query = 'SageCommand?context='+sage_instance+'&command=TV';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.Guide = function() { // Guide
	var query = 'SageCommand?context='+sage_instance+'&command=Guide';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.Info = function() { // Info
	var query = 'SageCommand?context='+sage_instance+'&command=Info';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.VidLibrary = function() { // Videos library
	var query = 'SageCommand?context='+sage_instance+'&command=Video%20Library';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.MusicLibrary = function() { // Music library
	var query = 'SageCommand?context='+sage_instance+'&command=Music%20Jukebox';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.PicLibrary = function() { // Pictures library
	var query = 'SageCommand?context='+sage_instance+'&command=Picture%20Library';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.recordButton = function() { // Record button
	var query = 'SageCommand?context='+sage_instance+'&command=Record';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.pauseButton = function() { // Pause button
	var query = 'SageCommand?context='+sage_instance+'&command=Pause';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.stopButton = function() { // Stop button
	var query = 'SageCommand?context='+sage_instance+'&command=Stop';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.frButton = function() { // Fast Rewind button
	var query = 'SageCommand?context='+sage_instance+'&command=Skip Bkwd/Page Left';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.playButton = function() { // Play button
	var query = 'SageCommand?context='+sage_instance+'&command=Play';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.ffButton = function() { // Fast Forward button
	var query = 'SageCommand?context='+sage_instance+'&command=Skip Fwd/Page Right';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.rskipButton = function() { // Reverse Skip button
	var query = 'SageCommand?context='+sage_instance+'&command=Skip%20Bkwd%20%232';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.delButton = function() { // Delete button
	var query = 'SageCommand?context='+sage_instance+'&command=Delete';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.fskipButton = function() { // Forward Skip button
	var query = 'SageCommand?context='+sage_instance+'&command=Skip%20Fwd%20%232';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num1Button = function() { // Number 1
	var query = 'SageCommand?context='+sage_instance+'&command=Num 1';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num2Button = function() { // Number 2
	var query = 'SageCommand?context='+sage_instance+'&command=Num 2';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num3Button = function() { // Number 3
	var query = 'SageCommand?context='+sage_instance+'&command=Num 3';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num4Button = function() { // Number 4
	var query = 'SageCommand?context='+sage_instance+'&command=Num 4';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num5Button = function() { // Number 5
	var query = 'SageCommand?context='+sage_instance+'&command=Num 5';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num6Button = function() { // Number 6
	var query = 'SageCommand?context='+sage_instance+'&command=Num 6';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num7Button = function() { // Number 7
	var query = 'SageCommand?context='+sage_instance+'&command=Num 7';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num8Button = function() { // Number 8
	var query = 'SageCommand?context='+sage_instance+'&command=Num 8';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num9Button = function() { // Number 9
	var query = 'SageCommand?context='+sage_instance+'&command=Num 9';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.num0Button = function() { // Number 0
	var query = 'SageCommand?context='+sage_instance+'&command=Num 0';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.chUpButton = function() { // Channel Up
	var query = 'SageCommand?context='+sage_instance+'&command=Channel Up/Page Up';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.chDownButton = function() { // Channel Down
	var query = 'SageCommand?context='+sage_instance+'&command=Channel Down/Page Down';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.lastChButton = function() { // 
	var query = 'SageCommand?context='+sage_instance+'&command=Previous Channel';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.volUpButton = function() { // Volume Up
	var query = 'SageCommand?context='+sage_instance+'&command=Volume UP';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.volDownButton = function() { // Volume Down
	var query = 'SageCommand?context='+sage_instance+'&command=Volume Down';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.muteButton = function() { // Mute
	var query = 'SageCommand?context='+sage_instance+'&command=Mute';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.arrowUpButton = function() { // Up Arrow
	var query = 'SageCommand?context='+sage_instance+'&command=UP';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.arrowLeftButton = function() { // Left Arrow
	var query = 'SageCommand?context='+sage_instance+'&command=Left';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.arrowRightButton = function() { // Right Arrow
	var query = 'SageCommand?context='+sage_instance+'&command=Right';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.arrowDownButton = function() { // Down Arrow
	var query = 'SageCommand?context='+sage_instance+'&command=Down';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.enterButton = function() { // Enter
	var query = 'SageCommand?context='+sage_instance+'&command=Select';
	new Ajax.Request(url + query, {
		method: 'get'
	});
}

MainAssistant.prototype.handleCommand = function(event) {
	if(event.type == Mojo.Event.command) {
		switch(event.command)
		{
			case 'cmd-back':
				var query = 'SageCommand?context='+sage_instance+'&command=Back';
				new Ajax.Request(url + query, {
					method: 'get'
				});
			break;
			case 'cmd-fwrd':
				var query = 'SageCommand?context='+sage_instance+'&command=Forward';
				new Ajax.Request(url + query, {
					method: 'get'
				});
			break;
		}
	}
}